package kk.learn.java.tomcat.demo1;

import server.HttpProtocolUtil;
import server.HttpServlet;
import server.Request;
import server.Response;

import java.io.IOException;

/**
 * <p>
 *
 * </p>
 *
 * @author KK
 * @since 2021-09-05
 */
public class Demo1Servlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
        try {
            String content = "hello demo1";
            System.out.println(content);
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        doGet(request, response);
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destory() throws Exception {

    }
}
